﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BGCOP.CAVTOP.WINFORMS
{
    public partial class frmPruebaFuentecs : Form
    {
        public frmPruebaFuentecs()
        {
            InitializeComponent();
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // Create a private font collection
            var pfc = new PrivateFontCollection();
            string path;
            path = Path.GetDirectoryName(Application.ExecutablePath);
            // Load in the temporary barcode font
            pfc.AddFontFile(path + "\\DLLWEB\\free3of9.ttf");

            // Select the font family to use
            FontFamily family = new FontFamily("Free 3 of 9", pfc);

            // Create the font object with size 30
            Font c39Font = new Font(family, 60);
            textBox1.Font = c39Font;

            textBox1.ForeColor = Color.Black;
            textBox1.Text = "*123456*";
            var objGraphics = pictureBox1.CreateGraphics();

            // Create a temporary bitmap...
            //Bitmap tmpBitmap = new Bitmap(1, 1, PixelFormat.Format32bppArgb);
            //var objGraphics = Graphics.FromImage(tmpBitmap);
            //// measure the barcode size...
            SizeF barCodeSize = objGraphics.MeasureString("*123456789*", c39Font);
            objGraphics.DrawString("*123456789*", c39Font, new SolidBrush(Color.Black), 0, 0);
            //try
            //{
            //    tmpBitmap.Save("c:\\cb.bmp");
            //}
            //catch (Exception ex)
            //{


            //}

            //pictureBox1.Image = new Bitmap(tmpBitmap);
        }
    }
}
